#pragma once

#include<memory>
#include<functional>
#include"Protocol.hpp"

enum{
    Div_Zero=1,
    Mod_Zero,
    Other_Oper
};
//上层业务
class Calculator
{
public:
    Response CalculatorHelper(const Request& req)
    {
        Response res(0,0);
        switch(req.op)
        {
            case '+':
                res.result=req.x+req.y;
                break;
            case '-':
                res.result=req.x-req.y;
                break;
            case '*':
                res.result=req.x*req.y;
                break;
            case '/':
                if(req.y==0)
                    res.code=Div_Zero;
                else{
                    res.result=req.x/req.y;
                }
                break;
            case '%':
                if(req.y==0)
                    res.code==Mod_Zero;
                else{
                    res.result=req.x%req.y;
                }
                break;
            default:
                res.code=Other_Oper;
                break;
        }
        return res;
    }
    std::string Handler(std::string& package)
    {
        
    }

};